package io.github.maojian.bianrysearch;

import java.util.ArrayList;
import java.util.List;

/**
 * @Auther: jian.mao
 * @Date: 2022-07-05 09:13
 * @Description: https://leetcode.cn/problems/my-calendar-i/
 */
public class Q729 {
    private List<int[]> list;

    public Q729() {
        list = new ArrayList<>();
    }

    public boolean book(int start, int end) {
        for (int[] arr : list) {
            if (arr[0] < end && start < arr[1]) {
                return false;
            }
        }
        list.add(new int[]{start, end});
        return true;
    }

    public static void main(String[] args) {
        Q729 q729 = new Q729();
        System.out.println(q729.book(10, 20));
        System.out.println(q729.book(15, 25));
        System.out.println(q729.book(20, 30));
    }
}
